package com.mynews.mvp.presenter;

import com.mynews.bean.DailyListBean;
import com.mynews.common.CommonNetSubscriber;
import com.mynews.mvp.model.LatestDailyModel;
import com.mynews.mvp.view.LatestDailyViewInterface;

/**
 * Created by Administrator on 2017/6/23.
 */

public class LatestDailyPresenter {
    private static final String TAG = LatestDailyPresenter.class.getSimpleName();
    private LatestDailyViewInterface viewInterface;
    private LatestDailyModel model;
    public LatestDailyPresenter(LatestDailyViewInterface viewInterface){
        this.viewInterface = viewInterface;
        model = new LatestDailyModel();
    }

    public void doLoadData(){
        model.getLatestDaily().subscribe(new CommonNetSubscriber<DailyListBean>() {
            @Override
            public void onStart() {
                super.onStart();
            }
            @Override
            public void onCompleted() {
                super.onCompleted();
            }
            @Override
            public void onError(Throwable e) {
                super.onError(e);
                viewInterface.LatestDilyError();
            }
            @Override
            public void onNext(DailyListBean dailyListBean) {
                super.onNext(dailyListBean);
                viewInterface.LatestDailyDisView(dailyListBean);
            }
        });
    }

    public void doLoadBeforeData(String date){
        model.getDailyBeforeList(date).subscribe(new CommonNetSubscriber<DailyListBean>() {

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                viewInterface.BeforeDailyError();
            }
            @Override
            public void onNext(DailyListBean dailyBeforeListBean) {
                super.onNext(dailyBeforeListBean);
                viewInterface.BeforeDailyShowContent(dailyBeforeListBean);
            }
        });
    }



}
